package com.ruoyi.behindExamination.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.behindExamination.domain.DocExamination;
import com.ruoyi.behindExamination.service.IDocExaminationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 体检记录表Controller
 * 
 * @author ruoyi
 * @date 2025-08-14
 */
@RestController
@RequestMapping("/behindExamination/docExamination")
public class DocExaminationController extends BaseController
{
    @Autowired
    private IDocExaminationService docExaminationService;

    /**
     * 查询体检记录表列表
     */
    @PreAuthorize("@ss.hasPermi('behindExamination:docExamination:list')")
    @GetMapping("/list")
    public TableDataInfo list(DocExamination docExamination)
    {
        startPage();
        List<DocExamination> list = docExaminationService.selectDocExaminationList(docExamination);
        return getDataTable(list);
    }

    /**
     * 导出体检记录表列表
     */
    @PreAuthorize("@ss.hasPermi('behindExamination:docExamination:export')")
    @Log(title = "体检记录表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DocExamination docExamination)
    {
        List<DocExamination> list = docExaminationService.selectDocExaminationList(docExamination);
        ExcelUtil<DocExamination> util = new ExcelUtil<DocExamination>(DocExamination.class);
        util.exportExcel(response, list, "体检记录表数据");
    }

    /**
     * 获取体检记录表详细信息
     */
    @PreAuthorize("@ss.hasPermi('behindExamination:docExamination:query')")
    @GetMapping(value = "/{examinationId}")
    public AjaxResult getInfo(@PathVariable("examinationId") Long examinationId)
    {
        return success(docExaminationService.selectDocExaminationByExaminationId(examinationId));
    }

    /**
     * 新增体检记录表
     */
    @PreAuthorize("@ss.hasPermi('behindExamination:docExamination:add')")
    @Log(title = "体检记录表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DocExamination docExamination)
    {
        return toAjax(docExaminationService.insertDocExamination(docExamination));
    }

    /**
     * 修改体检记录表
     */
    @PreAuthorize("@ss.hasPermi('behindExamination:docExamination:edit')")
    @Log(title = "体检记录表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DocExamination docExamination)
    {
        return toAjax(docExaminationService.updateDocExamination(docExamination));
    }

    /**
     * 删除体检记录表
     */
    @PreAuthorize("@ss.hasPermi('behindExamination:docExamination:remove')")
    @Log(title = "体检记录表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{examinationIds}")
    public AjaxResult remove(@PathVariable Long[] examinationIds)
    {
        return toAjax(docExaminationService.deleteDocExaminationByExaminationIds(examinationIds));
    }
}
